package Test;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;


public class TestDemo2 {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        String str = new String("abc");
        Field value = str.getClass().getDeclaredField("value");
        value.setAccessible(true);
        value.set(str,"abcd".toCharArray());
        System.out.println(str);
        File file = new File("D:\\easypan\\file\\avatar");
        FutureTask<Integer> futureTask = new FutureTask<>(()->{return 1;});
        Thread thread = new Thread(futureTask);
        thread.start();


    }
    public static void main2(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        String str = "123";
        Class<? extends String> aClass = str.getClass();   //获取到类对象
        System.out.println(aClass.getName());
        Method[] methods = aClass.getMethods();
        System.out.println(methods.length);
        Constructor<? extends String> declaredConstructor = aClass.getDeclaredConstructor();
        String s = declaredConstructor.newInstance();
        s = "d";
        System.out.println(s);
    }
    public static void main1(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new PrintThread(1, "Hello"));
        Thread t2 = new Thread(new PrintThread(2, "World"));
        Thread t3 = new Thread(new PrintThread(3, "!"));

        // 启动线程
        t1.start();
        t1.join();

        t2.start();
        t2.join();

        t3.start();
        t3.join();
    }
}

class PrintThread implements Runnable {
    private int threadNum;
    private String content;

    public PrintThread(int threadNum, String content) {
        this.threadNum = threadNum;
        this.content = content;
    }

    @Override
    public void run() {
        System.out.println("Thread " + threadNum + ": " + content);
    }
}